package com.datasure.converter;

import com.datasure.domain.entity.Device;
import com.datasure.presistence.dataobject.DeviceDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author zhangxiaolong
 * @ClassName DeviceDataConverter.java
 * @Description DeviceData转换类
 * @createTime 2022年01月13日 12:53:00
 */
@Mapper
public interface DeviceDataConverter {

    DeviceDataConverter INSTANCE = Mappers.getMapper(DeviceDataConverter.class);

    @Mappings({
            @Mapping(target = "deviceId", source = "deviceId.id")
    })
    DeviceDO toData(Device device);


    @Mappings({
//            @Mapping(target = "deviceId.id", source = "deviceDO.deviceId"),
            @Mapping(target = "deviceId", ignore = true)
//            @Mapping(target = "deviceUniqueId", source = "deviceDO.deviceUniqueId")
    })
    Device fromData(DeviceDO deviceDO);
}
